﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace LibraryManagement
{
    /// <summary>
    /// 
    /// </summary>
    /// <remarks></remarks>
    public partial class DBController
    {
        #region ReadData

        /// <summary>
        /// Gets the GMIB list.
        /// </summary>
        /// <param name="productID">The product ID.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        //public static DataTable GetAuthorListsql()
        //{
        //    using (DAL dal = new DAL())
        //    {
        //        DataTable dt = dal.ExecuteDataTableSQL("dbo.GetAuthorDetails");
        //        return dt;
        //    }
        //}

        /// <summary>
        /// Gets the author list.
        /// </summary>
        /// <param name="authorID">The author ID.</param>
        /// <param name="authorName">Name of the author.</param>
        /// <returns></returns>
        public static DataTable GetAuthorList(Object authorID, Object authorName)
        {
            DataTable dt = new DataTable();
            using (DAL dal = new DAL())
            {
                dt = dal.ExecuteDataTable("dbo.GetAuthorDetails", authorID, authorName);
            }
            return dt;
        }

        /// <summary>
        /// Deletes the author.
        /// </summary>
        /// <param name="authorID">The author ID.</param>
        public static void DeleteAuthor(Int32 authorID)
        {
            using (DAL dal = new DAL())
            {
                dal.ExecuteNonQuery("deleteAuthor", authorID);
            }
        }

    
        #endregion

        #region SaveData

        /// <summary>
        /// Ius the author.
        /// </summary>
        /// <param name="authorName">Name of the author.</param>
        public static void InsertUpdateAuthor(Object authorID, Object authorName)
        {
            using (DAL dal = new DAL(true))
            {
                try
                {
                    dal.ExecuteNonQuery("dbo.iuAuthor",authorID ,authorName);
                    dal.CommitTransaction();
                }
                catch
                {
                    dal.RollBackTransaction();
                }
            }
        }
        
       
        #endregion
    }
}
